package com.situ.student.service.impl;

import java.util.List;

import com.situ.student.dao.IStudentDao;
import com.situ.student.dao.impl.StudentDaoJdbcImpl;
import com.situ.student.entity.Student;
import com.situ.student.service.IStudentService;

public class StudentServiceImpl implements IStudentService {
	private IStudentDao studentDao = new StudentDaoJdbcImpl();

	/**
	 * 增加学生
	 */
	@Override
	public boolean insert(Student student) {
		int count = studentDao.insert(student);
		return count == 1 ? true : false;
	}

	/**
	 * 读取所有学生
	 */
	@Override
	public List<Student> list() {
		return studentDao.list();
	}

	/**
	 * 删除学生
	 */
	@Override
	public boolean deleteById(Integer id) {
		int count = studentDao.deleteById(id);
		return count == 1 ? true : false;
	}

	/**
	 * 搜索学生
	 */
	@Override
	public List<Student> findByName(String name) {
		return studentDao.findByName(name);
	}

	/**
	 * 修改学生
	 */
	@Override
	public boolean updateStudent(Student student) {
		int count = studentDao.updateStudent(student);
		return count == 1 ? true : false;
	}
}
